package basic

import "fmt"

func Fibonacci(c, quit chan int) {
	x, y := 0, 1
	for {
		select {
		case c <- x:
			x, y = y, x+y
		case <-quit:
			fmt.Println("Quit")
			return
		}
	}
}

func BasicDefer() {
	// 4,3,2,1,0 先defer的后面出
	for i := 0; i < 5; i++ {
		defer fmt.Println(i)
	}

	defer fmt.Println("--------------------")
}

func BasicKeyWord() {
	BasicDefer()
}
